#coding: utf-8
class Admin::ClientLogsController < AdminController

  set_tab :developers
  set_tab :client_logs, :sub_nav
  before_filter :setup, only: [:index]
  respond_to :html, :json

  def index
    params[:client_log] ||= {}
    @client_logs = ClientLog
    @client_logs = @client_logs.where(remote_ip: params[:client_log][:remote_ip]) unless params[:client_log][:remote_ip].blank?
    @client_logs = @client_logs.where(client_id: params[:client_log][:client_id]) unless params[:client_log][:client_id].blank?
    @client_logs = @client_logs.where(client_type: params[:client_log][:client_type]) unless params[:client_log][:client_type].blank?
    @client_logs = @client_logs.where(log_type: params[:client_log][:log_type]) unless params[:client_log][:log_type].blank?
    @client_logs = @client_logs.before_date(params[:client_log][:end_date]) unless params[:client_log][:end_date].blank?
    @client_logs = @client_logs.after_date(params[:client_log][:start_date]) unless params[:client_log][:start_date].blank?
    @client_logs = @client_logs.order('created_at desc').page params[:page]
  end

  private

  def setup
    @ways = ["日志管理","客户端日志"]
    @left_panel = "layouts/developer_left_panel"
  end

end
